package com.mjh.zhujianju.controller.set;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.livew.framework.base.controller.BaseController;
import com.livew.framework.base.service.BaseService;
import com.livew.framework.exception.XTBusinessException;
import com.livew.framework.pojo.AjaxResult;
import com.livew.framework.utils.XTListUtils;
import com.mjh.zhujianju.model.set.NavigationEO;
import com.mjh.zhujianju.service.set.NavigationService;
import com.mjh.zhujianju.vo.set.NavigationVO;

@Controller
@RequestMapping("set/navigation")
public class NavigationController extends BaseController<NavigationEO>{

	@Resource
	private NavigationService navigationService;

	@Override
	protected BaseService<NavigationEO> getService() {
		return navigationService;
	}
	
	
	/**
	 * 更新
	 * @param vo
	 * @return
	 */
	@RequestMapping(value = "updateInfo", method = RequestMethod.POST)
	@ResponseBody
	public AjaxResult updateInfo(NavigationVO  avigation) {
		if (avigation==null||XTListUtils.isEmpty(avigation.getNavigationList())) {
			return AjaxResult.getResult(Boolean.FALSE, "参数错误");
		}
		try {
			navigationService.updateInfo(avigation.getNavigationList());
		} catch (XTBusinessException e) {
			e.printStackTrace();
			return AjaxResult.getResult(Boolean.FALSE, e.getMessage());
		}
		return AjaxResult.getResult(Boolean.TRUE, "更新成功");
	}
	
	
	/**
	 * 更新
	 * @param vo
	 * @return
	 */
	@RequestMapping(value = "getAll", method = RequestMethod.GET)
	@ResponseBody
	public AjaxResult getAll() {
		List<NavigationEO> list= navigationService.getAll();
		return AjaxResult.getResult(list);
	}
	
	
}
